<?php
defined('IN_TS') or die('Access Denied.');
/* 
 * 搜索
 */

$q = isset($_GET['q']) ? $_GET['q'] : '';
if(empty($q)) $q="输入内容不能为空";

switch($ts){
	//搜索小组
	case "搜索小组":
		
		//奶奶的全文索引索不出蛋来啊
		//$arrGroup = $DB->fetch_all_assoc("select * from ".dbprefix."app_mgroup WHERE MATCH (groupname,groupdesc) AGAINST ('".$q."')");
		
		$arrGroups = $DB->fetch_all_assoc("select groupid from ".dbprefix."app_group WHERE groupname like '%$q%' or groupdesc like '%$q%'");
		
		if(is_array($arrGroups)){
			foreach($arrGroups as $item){
				$arrGroup[] = $new['group']->getOneGroup($item['groupid']);
			}
		}

		$title ='搜索包含'.$q.'的小组';
		
		include TmooTemplate("search_group");
		
		break;
	
	//搜索帖子
	case "搜索话题":
	
		//$arrTopic = $DB->fetch_all_assoc("select * from ".dbprefix."app_group_topics WHERE title like '%$q%' or content like '%$q%'");
		$arrTopic = $DB->fetch_all_assoc("select * from ".dbprefix."app_group_topics WHERE title like '%$q%'");
		
		$title ='搜索有关'.$q.'的帖子';
		
		include TmooTemplate("search_topic");
		break;
}
